﻿//using System;
//using System.Collections.Generic;
//using System.Configuration;
//using System.Data;
//using System.Data.SqlClient;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace CodeAngel.Domain
//{
//    public static class FriendlyIdService
//    {
//        /// <summary>
//        /// Gets the next friendly id for the identified entity type.
//        /// </summary>
//        public static int GetNextFriendlyID(string entityName)
//        {
//            string ConnectionString = ConfigurationManager.ConnectionStrings["DomainDatabaseConnection"].ConnectionString;
//            using (var ThisConnection = new SqlConnection(ConnectionString))
//            {
//                try
//                {
//                    ThisConnection.Open();

//                    SqlCommand ThisCommand = new SqlCommand();
//                    ThisCommand.Connection = ThisConnection;
//                    ThisCommand.CommandType = CommandType.StoredProcedure;
//                    ThisCommand.CommandText = "GetNextFriendlyID";

//                    ThisCommand.Parameters.AddWithValue("@EntityName", entityName);
//                    var NextFriendlyIdParameter = ThisCommand.Parameters.Add("@NextFriendlyID", SqlDbType.Int);
//                    NextFriendlyIdParameter.Direction = ParameterDirection.Output;

//                    ThisCommand.ExecuteNonQuery();
//                    return Convert.ToInt32(NextFriendlyIdParameter.Value);
//                }
//                catch (Exception ex)
//                {
//                    throw new Exception("There was an unexpected problem geting the next friendly id for " + entityName, ex);
//                }
//                finally
//                {
//                    if (ThisConnection != null && ThisConnection.State != ConnectionState.Closed) ThisConnection.Close();
//                }
//            }
//        }
//    }
//}
